package br.com.firula.to;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="torcida")
@SequenceGenerator(name="SEQUENCE", sequenceName="torcida_seq")
@Inheritance(strategy=InheritanceType.JOINED)
public class TorcidaTO extends BaseTO{

	private static final long serialVersionUID = -6646960056050339384L;

	@Id
	@Column(name="id", nullable=false)
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;

	@Column(name="nome", nullable=false)
	private String nome;

	@Column(name="descricao")
	private String descricao;

	@ManyToMany(fetch = FetchType.LAZY, mappedBy="torcidas", targetEntity=UsuarioTO.class)
	private List<UsuarioTO> usuarios;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="rel_torcida_time",
        joinColumns=@JoinColumn(name="idTime", nullable = false, referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="idTorcida", nullable = false, referencedColumnName="id"))
	private List<TimeTO> times;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public List<UsuarioTO> getUsuarios() {
		return usuarios;
	}

	public void setUsuarios(List<UsuarioTO> usuarios) {
		this.usuarios = usuarios;
	}

	public List<TimeTO> getTimes() {
		return times;
	}

	public void setTimes(List<TimeTO> times) {
		this.times = times;
	}

	@Override
	public String getAbreviation() {
		// TODO Auto-generated method stub
		return null;
	}

}
